<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>kill</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_263">&nbsp;</a>NAME</h4><blockquote>
kill - send a signal to a process or a group of processes
</blockquote><h4><a name = "tag_000_007_264">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="systypes.h.html">sys/types.h</a>&gt;
#include &lt;<a href="signal.h.html">signal.h</a>&gt;

int kill(pid_t <i>pid</i>, int <i>sig</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_265">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>kill()</i>
function will send a signal to a process or a group of processes
specified by
<i>pid</i>.
The signal to be sent is specified by
<i>sig</i>
and is either one from the list given in
<i><a href="signal.h.html">&lt;signal.h&gt;</a></i>
or 0.  If
<i>sig</i>
is 0 (the null signal), error checking is performed but no signal is actually
sent.  The null signal can be used to check the validity of
<i>pid</i>.
<p>
{_POSIX_SAVED_IDS} will be defined on all XSI-conformant systems, and
for a process to have permission to send a signal to a process
designated by
<i>pid</i>,
the real or effective user ID of the sending process must match
the real or
saved set-user-ID
of the receiving process, unless
the sending process has appropriate privileges.
<p>
If
<i>pid</i>
is greater than 0,
<i>sig</i>
will be sent to the process whose process ID is equal to
<i>pid</i>.
<p>
If
<i>pid</i>
is 0,
<i>sig</i>
will be sent to all processes
(excluding an unspecified set of system processes)
whose process
group ID is equal to the process group ID of the sender, and for
which the process has permission to send a signal.
<p>
If
<i>pid</i>
is -1,
<i>sig</i>
will be sent to all processes
(excluding an unspecified set of system processes)
for which the process has permission to send that signal.
<p>
If
<i>pid</i>
is negative, but not -1,
<i>sig</i>
will be sent to all processes
(excluding an unspecified set of system processes)
whose process group ID is equal to
the absolute value of
<i>pid</i>,
and for which the process has permission to send a signal.
<p>
If the value of
<i>pid</i>
causes
<i>sig</i>
to be generated for the sending process, and if
<i>sig</i>
is not blocked
for the calling thread and if no other thread has
<i>sig</i>
unblocked or is waiting in a
<i><a href="sigwait.html">sigwait()</a></i>
function for
<i>sig</i>,
either
<i>sig</i>
or at least one pending unblocked signal will be delivered to the
sending thread
before
<i>kill()</i>
returns.
<p>
The user ID tests described above will not be applied when sending SIGCONT to
a process that is a member of the same session as the sending process.
<p>
An implementation that provides extended security controls may
impose further implementation-dependent restrictions on the sending
of signals, including the null signal.
In particular, the system may deny the existence of some or all
of the processes specified by
<i>pid</i>.
<p>
The
<i>kill()</i>
function is successful if the process has permission to send
<i>sig</i>
to any of the processes specified by
<i>pid</i>.
If
<i>kill()</i>
fails, no signal will be sent.
</blockquote><h4><a name = "tag_000_007_266">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion, 0 is returned.
Otherwise, -1 is returned and
<i>errno</i>
is set to indicate the error.
<br>
</blockquote><h4><a name = "tag_000_007_267">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>kill()</i>
function will fail if:
<dl compact>

<dt>[EINVAL]<dd>
The value of the
<i>sig</i>
argument is an invalid or unsupported signal number.

<dt>[EPERM]<dd>
The process does not have permission to send the signal to any
receiving process.

<dt>[ESRCH]<dd>
No process or process group can be found corresponding to that
specified by
<i>pid</i>.

</dl>
</blockquote><h4><a name = "tag_000_007_268">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_269">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_270">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_271">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="getpid.html">getpid()</a></i>,
<i><a href="raise.html">raise()</a></i>,
<i><a href="setsid.html">setsid()</a></i>,
<i><a href="sigaction.html">sigaction()</a></i>,
<i><a href="signal.h.html">&lt;signal.h&gt;</a></i>,
<i><a href="sigqueue.html">sigqueue()</a></i>,
<i><a href="systypes.h.html">&lt;sys/types.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from Issue 1 of the SVID.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

